package com.summer.core.form.design;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.dom4j.Document;
import org.dom4j.Element;

import com.summer.core.util.SysPath;
import com.summer.core.util.XmlHelper;

public class Layout {
	private final static String xmlfile=SysPath.getRealPath("table.xml");
	private List<String> list;
	public List<String> getLayoutDiv()
	{
		list=new ArrayList<String>();
        try {
            Document doc = XmlHelper.parseXml(xmlfile);
            List nodes = doc.selectNodes("//div");
            Iterator<Element> i = nodes.iterator();
            int cc=1;
            while(i.hasNext()) {
                Element temp = i.next();
                Iterator<Element> j=temp.elementIterator();
                
                while(j.hasNext())
                {Element temp1 = j.next();
                StringBuffer str=new StringBuffer();
                str.append("<div id='layer"+cc+"' class='field' onmousedown='layerOnDrag()' onclick='layerOnClick()' name='remark' ");
                str.append("type='"+temp1.getName()+"'>");
                str.append(temp1.attributeValue("name"));
                str.append("</div>");
                list.add(str.toString());
                cc++;
                }
            }
        	}catch(Exception e){
        		e.printStackTrace();
        }
		
		
		return list;
	}
	
	public static void main(String[] args) {
		
		
		new Layout().getLayoutDiv();
	}

}
